<!-- 车辆基本信息 -->
<!DOCTYPE>
<html>

<head>
    <%- include ../taglib/layout-table.ejs %>

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content" style="padding:5px">
    <div class="row animated fadeInDown">
        <div class="col-sm-3">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>设备数据</h5>
                </div>
                <div class="ibox-content  pre-scrollable">
                    <div id='external-events'>
                        <ul id="kindTree" class="ztree">
                        </ul>
                    </div>
                </div>
            </div>

        </div>
        <div class="col-sm-9 clearfix" style="padding-left:5px">
            <div class="row">
                <div class="col-sm-12">
                    <div class="ibox float-e-margins ">
                        <div class="ibox-title">
                            <h5>查询条件</h5>

                            <div class="ibox-tools">
                                <a class="collapse-link">
                                    <i class="fa fa-chevron-up"></i>
                                </a>
                            </div>
                        </div>
                        <div class="ibox-content">
                            <div class="row">
                                <div class="pull-right">
                                    <form role="form" class="form-inline ">

                                        <div class="form-group">
                                            <label class="control-label">终端列表：</label>
                                        </div>

                                        <div class="input-group div-serch-input">
                                            <select class="form-control m-b" id="baseTerminalIdsearch"
                                                    name="baseTerminalIdsearch" type="select " style="width: 200px">

                                            </select>
                                            <span class="input-group-btn">
                                                <button type="button" class="btn btn btn-primary" onclick="query(3)"><i
                                                            class="fa fa-search"></i> 搜索
                                                </button>
                                            </span>


                                            <input type="text" placeholder="请录入车牌号查询" class="input form-control"
                                                   id="serchStr">
                                            <span class="input-group-btn">
                                                <button type="button" class="btn btn btn-primary" onclick="query(2)"><i
                                                    class="fa fa-search"></i> 搜索
                                                </button>
                                            </span>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-12">

                    <div class="ibox float-e-margins ">
                        <div class="ibox-title">
                            <h5>数据列表</h5>

                            <div class="ibox-tools">
                            </div>
                        </div>
                        <div class="ibox-content">

                            <div class="" id="">
                                <button class="btn btn-primary " type="button" onclick="addsimpal()"><i
                                            class="fa fa-check"></i>&nbsp;快速新增
                                </button>
                                <button class="btn btn-primary " type="button" onclick="add()"><i
                                            class="fa fa-check"></i>&nbsp;详细新增
                                </button>
                                <button class="btn btn-primary " type="button" onclick="openImport()"><i
                                            class="fa fa-check"></i>&nbsp;导入文件
                                </button>
                                <button class="btn btn-danger " type="button" onclick="dels()"><i
                                            class="fa fa-close"></i>
                                    批量删除
                                </button>
                                <div>
                                    <table id="example"
                                           class="table table-striped table-bordered table-hover dataTables-example">
                                        <thead>
                                        <tr>
                                            <th>
                                            </th>
                                            <th  width="220" class="show-detail-json">操作</th>

                                            <th>id</th>
                                            <th>客户</th>
                                            <th>tid</th>
                                            <th>cId</th>
                                            <th>所属用户</th>
                                            <th width="100">车牌号</th>
                                            <!--0px">车牌号颜色</th>-->
                                            <th width="100"> 品牌</th>
                                            <th width="100">车辆类型</th>
                                            <th width="50">排量</th>
                                            <!--0px">车辆图标</th>-->
                                            <th width="200">设备编号</th>
                                            <th width="200">设备sim</th>
                                            <th width="80">车主姓名</th>
                                            <th width="200">车主电话</th>
                                            <th width="50">别名</th>
                                            <th width="200">发动机号</th>
                                            <th width="200">机架号</th>
                                            <th width="70">燃料类型</th>
                                            <th width="200">省份</th>
                                            <th width="200">市区</th>
                                            <th width="70">初始里程</th>
                                            <th width="200">里程设置时间</th>
                                            <th width="200">车辆颜色</th>
                                            <th width="200">营运证编号</th>
                                            <th width="200">座位数量</th>
                                            <th width="200">载重(吨)</th>
                                            <th width="200">出厂日期</th>
                                            <th width="200">购买日期</th>
                                            <th width="200">里程补偿系数</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        </tbody>
                                    </table>

                                </div>
                                <div class="modal inmodal" id="myModal" role="dialog" data-width="500px"
                                     data-height="400px" aria-hidden="true">
                                    <div class="modal-dialog">
                                        <div class="modal-content animated bounceInRight">
                                            <div class="modal-header">
                                                <h4 class="modal-title">新增车辆基本信息</h4>
                                            </div>
                                            <div class="modal-body" style="max-height: 400px; ">

                                                <form class="form-horizontal m-t" id="editForm" method="get">
                                                    <input id="id" name="id" type="hidden">
                                                    <input id="deptId" name="deptId" type="hidden">
                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label">所属用户</label>

                                                        <div class="col-sm-8">
                                                            <input id="deptName" name="deptName" class="form-control"
                                                                   type="text" readonly="readonly">
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label">车牌号</label>

                                                        <div class="col-sm-8">
                                                            <input id="baseCarNo" name="baseCarNo" class="form-control"
                                                                   placeholder="车牌号必填" type="text" aria-required="true"
                                                                   aria-invalid="true">
                                                        </div>
                                                    </div>

                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label">车牌号颜色</label>

                                                        <div class="col-sm-8">
                                                            <select class="form-control m-b" id="baseCarNoColour"
                                                                    name="baseCarNoColour" type="text">
                                                                <option value="黄">黄</option>
                                                                <option value="白">白</option>
                                                                <option value="蓝">蓝</option>
                                                                <option value="黑">黑</option>
                                                            </select>


                                                        </div>
                                                    </div>


                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label">车辆品牌</label>

                                                        <div class="col-sm-8">
                                                            <input id="baseCarBrand" name="baseCarBrand"
                                                                   class="form-control"
                                                                    type="text" >
                                                            <!--可以增加提示-->
                                                            <!--<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 这里写点提示的内容</span>-->
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label">车辆类型</label>

                                                        <div class="col-sm-8">
                                                            <!--<input id="baseCarTypeId" name="baseCarTypeId"-->
                                                            <!--class="form-control"-->
                                                            <!--placeholder="车辆类型必填" type="text"-->
                                                            <!--aria-required="true" aria-invalid="true">-->

                                                            <select class="form-control m-b" id="baseCarTypeId"
                                                                    name="baseCarTypeId" type="select">
                                                            </select>

                                                            <!--可以增加提示-->
                                                            <!--<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 这里写点提示的内容</span>-->
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label">排量</label>

                                                        <div class="input-group spinner col-sm-8">

                                                            <input type="text" id="baseCarOutput" name="baseCarOutput"
                                                                   class="form-control" value="1" aria-required="true"
                                                                   aria-invalid="true" readonly="readonly"
                                                                  >

                                                            <div class="input-group-btn-vertical ">
                                                                <button class="btn btn-default" id="first-of-type"
                                                                        type="button"><i
                                                                            class="fa fa-caret-up"></i></button>
                                                                <button class="btn btn-default" id="last-of-type"
                                                                        type="button"><i
                                                                            class="fa fa-caret-down"></i></button>
                                                            </div>

                                                        </div>


                                                    </div>
                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label">设备编号</label>

                                                        <div class="col-sm-8">
                                                            <!--<input id="baseTerminalId" name="baseTerminalId"-->
                                                            <!--class="form-control" placeholder="设备地址必填" type="text"-->
                                                            <!--aria-required="true" aria-invalid="true">-->

                                                            <select class="form-control m-b" id="baseTerminalId"
                                                                    name="baseTerminalId" type="select">

                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label">车主姓名</label>

                                                        <div class="col-sm-8">
                                                            <input id="userName" name="userName" class="form-control"
                                                                   type="text">
                                                            <!--可以增加提示-->
                                                            <!--<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 这里写点提示的内容</span>-->
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label">车主电话</label>

                                                        <div class="col-sm-8">
                                                            <input id="userPhone" name="userPhone" class="form-control"
                                                                   type="text" >
                                                            <!--可以增加提示-->
                                                            <!--<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 这里写点提示的内容</span>-->
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label">车辆别名</label>

                                                        <div class="col-sm-8">
                                                            <input id="baseCarName" name="baseCarName"
                                                                   class="form-control"
                                                                  type="text" >
                                                            <!--可以增加提示-->
                                                            <!--<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 这里写点提示的内容</span>-->
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label">发动机号</label>

                                                        <div class="col-sm-8">
                                                            <input id="baseCarFdNo" name="baseCarFdNo"
                                                                   class="form-control"
                                                                   type="text" >
                                                            <!--可以增加提示-->
                                                            <!--<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 这里写点提示的内容</span>-->
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label">机架号</label>

                                                        <div class="col-sm-8">
                                                            <input id="baseCarJjNo" name="baseCarJjNo"
                                                                   class="form-control"
                                                                   type="text" >
                                                            <!--可以增加提示-->
                                                            <!--<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 这里写点提示的内容</span>-->
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label">燃料类型</label>

                                                        <div class="col-sm-8">
                                                            <!--<input id="baseCarRlType" name="baseCarRlType"-->
                                                            <!--class="form-control"-->
                                                            <!--placeholder="燃料类型必填" type="text"-->
                                                            <!--aria-required="true" aria-invalid="true">-->
                                                            <select class="form-control m-b" id="baseCarRlType"
                                                                    name="baseCarRlType" type="text">
                                                                <option value="汽油">汽油</option>
                                                                <option value="柴油">柴油</option>
                                                                <option value="新能源">新能源</option>
                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label">所属省份</label>

                                                        <div class="col-sm-8">
                                                            <input id="baseCarOfProvince" name="baseCarOfProvince"
                                                                   class="form-control"  type="text"
                                                                  >
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label">所属市区</label>

                                                        <div class="col-sm-8">
                                                            <input id="baseCarOfCity" name="baseCarOfCity"
                                                                   class="form-control"
                                                                  type="text" >
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label">初始里程</label>

                                                        <div class="col-sm-8">
                                                            <input id="baseCarDis" name="baseCarDis"
                                                                   class="form-control"
                                                                  type="text"
                                                                   number="true" maxlength="10">

                                                        </div>
                                                    </div>

                                                    <!-- add   col-->
                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label">车辆颜色</label>

                                                        <div class="col-sm-8">
                                                            <input id="baseBarColor" name="baseBarColor"
                                                                   class="form-control"
                                                                   type="text">

                                                        </div>
                                                    </div>


                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label">营运证编号</label>

                                                        <div class="col-sm-8">
                                                            <input id="baseCarServiceNo" name="baseCarServiceNo"
                                                                   class="form-control"
                                                                   type="text">

                                                        </div>
                                                    </div>


                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label">座位数量</label>

                                                        <div class="col-sm-8">
                                                            <input id="baseCarSeat" name="baseCarSeat"
                                                                   class="form-control"
                                                                   type="text" number="true" maxlength="2">

                                                        </div>
                                                    </div>

                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label">载重(吨)</label>

                                                        <div class="col-sm-8">
                                                            <input id="baseCarLoad" name="baseCarLoad"
                                                                   class="form-control"
                                                                   type="text" number="true" maxlength="3">

                                                        </div>
                                                    </div>

                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label">出厂日期</label>

                                                        <div class="col-sm-8">
                                                            <input id="baseCarFactory" name="baseCarFactory" class="laydate-icon form-control layer-date"
                                                                   type="text">

                                                        </div>
                                                    </div>

                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label">购买日期</label>

                                                        <div class="col-sm-8">
                                                            <input id="baseCarBuy" name="baseCarBuy" class="laydate-icon form-control layer-date"
                                                                   type="text">

                                                        </div>
                                                    </div>

                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label">里程补偿系数</label>

                                                        <div class="col-sm-8">
                                                            <input id="baseCarDisMake" name="baseCarDisMake"
                                                                   class="form-control"
                                                                   type="text" number="true" maxlength="4">

                                                        </div>
                                                    </div>

                                                    <!-- add --- end-->

                                                </form>
                                            </div>
                                            <div class="modal-footer">

                                                <button type="button" class="btn btn-white" onclick="closeModal()">关闭
                                                </button>
                                                <button type="button" class="btn btn-primary" onclick="save()">保存
                                                </button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="modal inmodal" id="myModalSimpal" role="dialog" data-width="500px"
                                     data-height="400px" aria-hidden="true">
                                    <div class="modal-dialog">
                                        <div class="modal-content animated bounceInRight">
                                            <div class="modal-header">
                                                <h4 class="modal-title">快速增车</h4>
                                            </div>
                                            <div class="modal-body" style="max-height: 400px; ">

                                                <form class="form-horizontal m-t" id="editFormFast" method="get">
                                                    <input id="id" name="id" type="hidden">
                                                    <input id="deptIdf" name="deptId" type="hidden">

                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label">所属用户</label>

                                                        <div class="col-sm-8">
                                                            <input id="deptName1" name="deptName" class="form-control"
                                                                   type="text" readonly="readonly">
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label">车牌号</label>

                                                        <div class="col-sm-8">
                                                            <input id="baseCarNo" name="baseCarNo" class="form-control"
                                                                   placeholder="车牌号必填" type="text" aria-required="true"
                                                                   aria-invalid="true">
                                                        </div>
                                                    </div>

                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label">设备编号</label>

                                                        <div class="col-sm-8">
                                                            <select class="form-control m-b" id="baseTerminalId_fast"
                                                                    name="baseTerminalId" type="select" readonly="readonly">

                                                            </select>
                                                        </div>
                                                    </div>

                                                </form>
                                            </div>
                                            <div class="modal-footer">

                                                <button type="button" class="btn btn-white" onclick="closeModalSimpal()">关闭
                                                </button>
                                                <button type="button" class="btn btn-primary" onclick="savefast()">保存
                                                </button>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                            </div>
                            <div class="modal fade" id="myModalImp">
                                <div class="modal-dialog" >
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" onclick="closeImport()">×</button>
                                            <h4 class="modal-title" id="NoPermissionModalLabel">文件上传</h4>
                                        </div>
                                        <div class="modal-body">
                                            <iframe id="NoPermissioniframe" width="100%" height="70%" frameborder="0"></iframe>
                                        </div>
                                        <!--<div class="modal-footer">-->
                                            <!--<button class="btn btn-default"  type="button" onclick="closeImport()" >    关  闭    </button>-->
                                        <!--</div>-->
                                    </div>
                                </div>
                            </div>
                    </div>


                </div>

            </div>
        </div>
    </div>
</div>
    <input type="hidden" id="h_all_car_id" name="carIds">


    <%- include ../taglib/layout-content.ejs %>

<script src="js/combox/comb-carType-data.js"></script>
<script src="js/combox/comb-terminal-data.js"></script>

<script type="text/javascript">
    var table;
    var validator,validatorfast;
    $(document).ready(function () {
        table = $('.dataTables-example').dataTable({
            "lengthChange": false,//是否允许用户自定义显示数量
//            "searching": false,//本地搜索
//            "scrollY": true,//dt高度
            "scrollY": "300px",
            "scrollCollapse": "true",
            scrollX: true,
            "autoWidth": true,//自动宽度
            "dom": '<"top"<"clear">>rt<"bottom"ilp<"clear">>',
//            "lengthChange": false,//是否允许用户自定义显示数量
            "ajax": {
                "url": "/baseCar/list",
//                "type": "POST",
                "dataSrc": "rows"
            },
            serverSide: true,
            columns: [
                {
                    "sClass": "text-center",
                    "data": "id",
                    'checkboxes': {
                        'selectRow': true,
                    }
                },
                {
                    "bSortable": false,//禁止排序
                    "orderable": false,
                    "sClass": "text-center",
                    data: function (d, e, f, g) {//这里给最后一列返回一个操作列表
                        //e是得到的json数组中的一个item ，可以用于控制标签的属性。
                        var id = d.id
                        var index = g.row
                        return '' +
                            '<button class="btn btn-info btn-sm btn-select-row" type="button" onclick="edit(' + index + ')" data-toggle="modal"   ><i class="fa fa-edit"></i> <span class="bold">编辑</span>' +
                            '<button class="btn btn-danger btn-sm btn-select-row" type="button"  onclick="del(' + id + ')" ><i class="fa fa-close"></i> <span class="bold">删除</span>';

                    }
                },
                {"sClass": "text-center", data: 'id'},
                {"sClass": "text-center", data: 'deptId'},
                {"sClass": "text-center", data: 'tId'},
                {"sClass": "text-center", data: 'cId'},
                {"sClass": "text-center", data: 'deptName'},
                {"sClass": "text-center", data: 'baseCarNo', "bSortable": false, "orderable": false},
//                {"sClass": "text-center", data: 'baseCarNoColour', "bSortable": false, "orderable": false},
                {"sClass": "text-center", data: 'baseCarBrand', "bSortable": false, "orderable": false},
                {"sClass": "text-center", data: 'baseCarTypeId', "bSortable": false, "orderable": false},
                {"sClass": "text-center", data: 'baseCarOutput', "bSortable": false, "orderable": false},
//                {"sClass": "text-center", data: 'baseCarIconId', "bSortable": false, "orderable": false},
                {"sClass": "text-center", data: 'baseTerminalId', "bSortable": false, "orderable": false},
                {"sClass": "text-center", data: 'baseTerminalSim', "bSortable": false, "orderable": false},
                {"sClass": "text-center", data: 'userName', "bSortable": false, "orderable": false},
                {"sClass": "text-center", data: 'userPhone', "bSortable": false, "orderable": false},
                {"sClass": "text-center", data: 'baseCarName', "bSortable": false, "orderable": false},
                {"sClass": "text-center", data: 'baseCarFdNo', "bSortable": false, "orderable": false},
                {"sClass": "text-center", data: 'baseCarJjNo', "bSortable": false, "orderable": false},
                {"sClass": "text-center", data: 'baseCarRlType', "bSortable": false, "orderable": false},
                {"sClass": "text-center", data: 'baseCarOfProvince', "bSortable": false, "orderable": false},
                {"sClass": "text-center", data: 'baseCarOfCity', "bSortable": false, "orderable": false},
                {"sClass": "text-center", data: 'baseCarDis', "bSortable": false, "orderable": false},
                {"sClass": "text-center", data: 'lastUpdateAt', "bSortable": false, "orderable": false},

//              add --- begin
                {"sClass": "text-center", data: 'baseBarColor', "bSortable": false, "orderable": false},
                {"sClass": "text-center", data: 'baseCarServiceNo', "bSortable": false, "orderable": false},
                {"sClass": "text-center", data: 'baseCarSeat', "bSortable": false, "orderable": false},
                {"sClass": "text-center", data: 'baseCarLoad', "bSortable": false, "orderable": false},
                {"sClass": "text-center", data: 'baseCarFactory', "bSortable": false, "orderable": false},
                {"sClass": "text-center", data: 'baseCarBuy', "bSortable": false, "orderable": false},
                {"sClass": "text-center", data: 'baseCarDisMake', "bSortable": false, "orderable": false}




//              add --- end





            ],
            //排序
//            'order': [[1, 'desc']],
            initComplete: function (setting, json) {
                //隐藏列
                debugger;
                visiblecolumn(2, false);
                visiblecolumn(3, false);
                visiblecolumn(4, false);
                visiblecolumn(5, false);
                visiblecolumn(6, false);
            },
        });

        //验证
        var cusrules = {
            rules: {
                memo: {
                    required: true,
                    //minlength: 3,
                    //maxlength: 20
                }, baseCarNo: {
                    required: true,
                    //minlength: 3,
                    //maxlength: 20
                }, baseTerminalId: {
                    required: true,
                    //minlength: 3,
                    //maxlength: 20
                }, baseTerminalSim: {
                    required: true,
                    //minlength: 3,
                    //maxlength: 20
                },
            },
            messages: {
                memo: {
                    required: icon + "请输入",
                    //minlength: icon + "必须3个字符以上",
                    //maxlength: icon + "必须20个字符以下"
                }, baseCarNo: {
                    required: icon + "请输入车牌号",
                    //minlength: icon + "车牌号必须3个字符以上",
                    //maxlength: icon + "车牌号必须20个字符以下"
                }, baseTerminalId: {
                    required: icon + "请输入设备id",
                    //minlength: icon + "设备id必须3个字符以上",
                    //maxlength: icon + "设备id必须20个字符以下"
                }, baseTerminalSim: {
                    required: icon + "请输入设备sim卡号",
                    //minlength: icon + "设备sim卡号必须3个字符以上",
                    //maxlength: icon + "设备sim卡号必须20个字符以下"
                },
            }

        };
        validator = $("#editForm").validate(cusrules);
        validatorfast = $("#editFormFast").validate(cusrules);
        loadComb("baseTerminalIdsearch", combTerminal);

//        下拉列表
        $("#myModal").on("shown.bs.modal", function () {
            loadComb("baseTerminalId", combTerminal);
            loadComb("baseCarTypeId", combCarType);

        });
        $("#myModalSimpal").on("shown.bs.modal", function () {
            loadComb("baseTerminalId_fast", combTerminal);

        });

        var start = {
            elem: '#baseCarFactory',
            format: 'YYYY-MM-DD hh:mm:ss',
            max: '2999-06-16 23:59:59', //最大日期

            istime: true,
            istoday: false,
            festival: true, //是否显示节日
            choose: function (datas) {
                end.min = datas; //开始日选好后，重置结束日的最小日期
                end.start = datas //将结束日的初始值设定为开始日
            }

        };
        var end = {
            elem: '#baseCarBuy',
            format: 'YYYY-MM-DD hh:mm:ss',
            max: '2999-06-16 23:59:59',
            istime: true,
            istoday: false,
            festival: true, //是否显示节日
            choose: function (datas) {
                start.max = datas; //结束日选好后，重置开始日的最大日期
            }
        };
        laydate(start);
        laydate(end);
        $("#start").val(laydate.now() + ' 00:00:00');
        $("#end").val(laydate.now() + ' 23:59:59');




    });
    //数字框
    (function ($) {
        $('.spinner .btn:first-of-type').on('click', function () {
            debugger;
            var num = parseFloat($('.spinner input').val());
            if (num < 9) {
                $('.spinner input').val((parseFloat($('.spinner input').val()) + 0.1).toFixed(1));
            }

        });
        $('.spinner .btn:last-of-type').on('click', function () {
            var num = parseFloat($('.spinner input').val());
//            if(!num){
//                num=0;
//            }
            if (num > 1) {
                $('.spinner input').val((parseFloat($('.spinner input').val()) - 0.1).toFixed(1));
            }


        });
    })(jQuery);




    function add() {
        //选择tree
        var selectedNode = tree_Obj.getSelectedNodes()[0];
        var selectName="无"
        debugger;
        if (selectedNode.isParent) {
            swal("选择错误", "此区域无法添加车辆!", "warning");
            return false;
        } else {
            selectName=selectedNode.name;
        }
        $.ajax({
            type: "GET",
            url: "/baseCar/create",
            cache: false,
            async: false,
            dataType: "json",
            success: function (data) {
                data.deptName=selectName;
                $('#editForm').loadDate(data);
                $("#myModal").modal("show");
            }
        });

    }
    function openImport() {
        //选择tree
        var selectedNode = tree_Obj.getSelectedNodes()[0];
        debugger;
        if (selectedNode.isParent) {
            swal("选择错误", "此区域无法添加车辆!", "warning");
            return false;
        } else {

        }
        var frameSrc = "<%= serverurl%>/baseCarExcel/index?deptId="+selectedNode.id;
        $("#NoPermissioniframe").attr("src", frameSrc);
//        $('#NoPermissionModal').modal({ show: true, backdrop: 'static' });
        $("#myModalImp").modal("show");

    }
    function closeImport() {
        $("#myModalImp").modal("hide");
    }
    function addsimpal() {
        //选择tree
        var selectedNode = tree_Obj.getSelectedNodes()[0];
        var selectName="无";
        debugger;
        if (selectedNode.isParent) {
            swal("选择错误", "此区域无法添加车辆!", "warning");
            return false;
        } else {
            selectName=selectedNode.name;
        }
        $.ajax({
            type: "GET",
            url: "/baseCar/create",
            cache: false,
            async: false,
            dataType: "json",
            success: function (data) {
                data.deptName=selectName;
                $('#editFormFast').loadDate(data);
                $("#myModalSimpal").modal("show");
            }
        });

    }
    function edit(index) {
        var data = table.DataTable().rows(index).data()
        if (data && data[0]) {
            loadComb("baseCarTypeId", combCarType);
            loadComb("baseTerminalId", combTerminal);
            data[0].baseTerminalId=data[0].tId;
            data[0].baseCarTypeId=data[0].cId;
            $('#editForm').loadDate(data[0]);
            $("#myModal").modal("show");
        } else {
            swal("已取消", "数据错误！", "warning");
        }
    }
    function del(id) {
        swal({
                    title: "您确定要删除这条信息吗",
                    text: "删除后将无法恢复，请谨慎操作！",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "是的，我要删除！",
                    cancelButtonText: "让我再考虑一下…",
                    closeOnConfirm: false,
                    closeOnCancel: false
                },
                function (isConfirm) {
                    if (isConfirm) {
                        $.ajax({
                            type: "GET",
                            url: "/baseCar/del",
                            cache: false,
                            async: false,
                            data: {
                                ids: id
                            },
                            dataType: "json",
                            success: function (data) {
//                            swal("删除成功！", "您已经永久删除了这条信息。", "success");
                                swal("删除成功！", data, "success");
                                query(1);
                            }
                        });

                    } else {
                        swal("已取消", "您取消了删除操作！", "error");
                    }
                });
    }
    function dels() {

        var rows = table.DataTable().rows('.selected').data();
        if (rows && rows.length >= 1) {

            var ids = "";
            rows.each(function (value) {
                ids += value.id + ",";
            })
            debugger;
            del(ids);
        } else {
            swal("系统提示", "请选择需要删除的数据！", "warning");
        }

    }
    function query(qtype) {
        var code;
        var jsonstr;

        if(qtype==1){
            var carIds=$("#h_all_car_id").val();
            if(carIds){
                code = $("#serchStr").val();
                jsonstr = [{"deptid": carIds},{"code": code}];
            }else {
                code = $("#serchStr").val();
                jsonstr = [{"deptid": "0,"},{"code": code}];
            }

        }else if(qtype==2){
            code = $("#serchStr").val();
            jsonstr = [{"basecarno": code},{"code": code}];
        }else if(qtype==3){
            debugger;
            code = $("#baseTerminalIdsearch").val();
            jsonstr = [{"baseterminalid": code},{"code": code}];
        }else{
            code = "";
            jsonstr = "";
        }
        table.DataTable().search(JSON.stringify(jsonstr), false, false).draw();
    }

    function savefast() {
        var selectedNode = tree_Obj.getSelectedNodes()[0];
        $("#deptIdf").val(selectedNode.id);
        $('#editFormFast').ajaxSubmit({
            type: 'post', // 提交方式 get/post
            dataType: 'json',
            url: '/baseCar/save', // 需要提交的 url
            beforeSubmit: function (formData, jqForm, options) {
                if (!$("#editFormFast").valid()) {
                    return false;
                }
            },
            success: function (data) {
                // data 保存提交后返回的数据，一般为 json 数据
                // 此处可对 data 作相关处理
                if (data.success) {
                    swal({
                        title: "系统提示",
                        text: data.msg,
                        type: "success"
                    });
                    $("#myModalSimpal").setDefForm(validatorfast);
                    $('#editFormFast').clearForm(true);
                    $("#myModalSimpal").modal("hide");
                    query(1);
                } else {
                    swal({
                        title: "系统提示",
                        text: data.msg,
                        type: "error"
                    });
                }
            },

        });
    }




    function save() {
        var selectedNode = tree_Obj.getSelectedNodes()[0];
        $("#deptId").val(selectedNode.id);
        $('#editForm').ajaxSubmit({
            type: 'post', // 提交方式 get/post
            dataType: 'json',
            url: '/baseCar/save', // 需要提交的 url
            beforeSubmit: function (formData, jqForm, options) {
                if (!$("#editForm").valid()) {
                    return false;
                }
            },
            success: function (data) {
                // data 保存提交后返回的数据，一般为 json 数据
                // 此处可对 data 作相关处理
                if (data.success) {
                    swal({
                        title: "系统提示",
                        text: data.msg,
                        type: "success"
                    });
                    $("#myModal").setDefForm(validator);
                    $('#editForm').clearForm(true);
                    $("#myModal").modal("hide");
                    query(1);
                } else {
                    swal({
                        title: "系统提示",
                        text: data.msg,
                        type: "error"
                    });
                }
            },

        });
    }
    function closeModal() {
        $("#myModal").setDefForm(validator);
        $("#deptName").val("");
        $("#myModal").modal("hide");
    }

    function closeModalSimpal() {
        $("#myModalSimpal").setDefForm(validatorfast);
        $("#deptName1").val("");
        $("#myModalSimpal").modal("hide");
    }


    //隐藏和显示列 c:列0开始，visible=false隐藏
    function visiblecolumn(c, visible) {
        debugger;
        table.DataTable().column(c).visible(visible)
    }
    function loadComb(id, data) {
        $("#" + id).select2({
            data: data,
            theme: "bootstrap",
            placeholder: '请选择',
            allowClear: true
        });
    }

    //    部门车辆树
    $(function () {
        var url = '/tree/dept';
        init_tree('id', 'parentId', 'name',  fnClick,fnCheck, "checkbox");
        loadMyTree(url);
    });

    //    树节点选中
//    var fnClick = function (event, treeId, treeNode) {
//
//        query(1);
//
//    }
    //    树节点选中
    var fnClick = function (event, treeId, treeNode) {
        var flag=treeNode.checked;
        tree_Obj.checkNode(treeNode, true, true);
        selectTreeNode(treeNode);


    }
    var fnCheck = function (event, treeId, treeNode, clickFlag) {
//        var flag=treeNode.checked;
//        tree_Obj.checkNode(treeNode, !flag, true);
        var ids=selectTreeNode(treeNode);

    }

    function selectTreeNode(treeNode) {
        var ids = setAllCarIds();
        query(1);
        return ids;
    }
    function setAllCarIds() {
        var checkNodes = tree_Obj.getCheckedNodes(true);
        var ids = "";
        $.each(checkNodes, function (key, value) {

//            var flag = value.isParent
//            if (flag && flag==false) {
                ids = ids + value.id + ","
//                carno=value.name;
//            }
        });
        $("#h_all_car_id").val(ids);
        return ids;
    }

</script>


</body>

</html>
